import javafx.scene.paint.Color;

public class Piece {
    private PieceType type;
    private int[][] shape;
    private int x;
    private int y;
    private Color color;
    
    public Piece(PieceType type) {
        this.type = type;
        this.shape = type.getShape();
        this.color = type.getColor();
        this.x = 0;
        this.y = 0;
    }
    
    public PieceType getType() {
        return type;
    }
    
    public int[][] getShape() {
        return shape;
    }
    
    public int getX() {
        return x;
    }
    
    public void setX(int x) {
        this.x = x;
    }
    
    public int getY() {
        return y;
    }
    
    public void setY(int y) {
        this.y = y;
    }
    
    public Color getColor() {
        return color;
    }
    
    public void rotateClockwise() {
        int rows = shape.length;
        int cols = shape[0].length;
        int[][] rotated = new int[cols][rows];
        
        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < cols; j++) {
                rotated[j][rows - 1 - i] = shape[i][j];
            }
        }
        
        shape = rotated;
    }
    
    public void rotateCounterClockwise() {
        int rows = shape.length;
        int cols = shape[0].length;
        int[][] rotated = new int[cols][rows];
        
        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < cols; j++) {
                rotated[cols - 1 - j][i] = shape[i][j];
            }
        }
        
        shape = rotated;
    }
}
